<%@ page import="com.nsu.evaluation.pojo.Role" %>
<%@ page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"
           uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>综合素质评价信息管理系统</title>
    <link rel="stylesheet" type="text/css" href="/lib/css/styles.css">
</head>
<body>
<div class="htmleaf-container">
    <div class="wrapper">
        <div class="container">
            <h1>欢迎登录</h1>
            <h2>综合素质评价信息管理系统</h2>
            <form class="login-form" id="loginform" method="post" accept-charset="UTF-8">
                <input type="text" id="username" name="username" placeholder="用户名">
                <input type="password" id="password" name="password" placeholder="密码">
                <select name="roleType">
                    ${requestScope.roleList }
                    <c:forEach items="${requestScope.roleList }" var="role">
                        <option value="${role.roleName }">${role.roleName }</option>
                    </c:forEach>
                    <%--<option value="评价管理员">评价管理员</option>--%>
                    <%--<option value="教师用户">教师用户</option>--%>
                    <%--<option value="学生用户">学生用户</option>--%>
                </select>

                <button type="submit" id="login-button" onclick="getForm()">登录</button>
            </form>
        </div>

        <ul class="bg-bubbles">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
</div>

<script src="/lib/js/jquery-2.1.1.min.js" type="text/javascript"></script>
<script>
    $('#login-button').click(function (event) {
        event.preventDefault();
        $('form').fadeOut(500);
        $('.wrapper').addClass('form-success');
    });
</script>

<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';color:#000000">
</div>
</body>
<script>
$(function(){
    $("#login-button").click(
        function() {
            $.ajax({
                url: '/api/user/userLogin',
                type: 'post',
                dataType: 'json',
                data:$('#loginform').serialize(),
                success: function (data) {
                    if (data.status == 0) {
                        alert("登陆成功");
                        window.location.href = data.msg;
                    } else {
                        alert("登录失败");
                        location.reload()
                    }
                },
                error : function(data) {
                    alert(data.msg);
                    location.reload()
                },
            });
        }
    );
});
</script>
</html>